import config from "uview-ui/libs/config/config";

const http = uni.$u.http
function getConfig(config) {
    return {
        ...config,
        header: {
            Accept: 'application/json'
        }
    }
}
// post请求，获取菜单
export default {
    login: (data, config = { noAuth: true }) => http.post('/member/login', data, getConfig(config)),
	register: (data, config = { noAuth: true }) => http.post('/member/register', data, getConfig(config)),
    deviceList: (data, config = {}) => http.get('/device/list', data, getConfig(config)),
    // 连接设备
    collectDevice: (data, config = {}) => http.post('/device/collect', data, getConfig(config)),
    // 连接记录
    connectionHistoryList: (data, config = {}) => http.post('/connectionHistory/list', data, getConfig(config)),
    memberDetail: (id, config = {}) => http.get(`/member/${id}`,{}, getConfig(config)),
    memberUpdate: (data, config = {}) => http.put(`/member/${data.id}`, data, getConfig(config)),
    memberList: (data, config = {}) => http.get('/member/list', data, getConfig(config)),
    // 设备详情
    deviceDetail: (id, config = {}) => http.get(`/device/${id}`, {},getConfig(config)),
    // 设备连接详情
    connectDetail: (id, config = {}) => http.get(`/connectionHistory/${id}`, {},getConfig(config)),
    // 更新设备启用状态
    updateEnableStatus: (data, config = {}) => http.put(`/device/enable`, data, getConfig(config)),
    // 设备数据
    deviceDataList: (data, config = {}) => http.post('/deviceData/list', data, getConfig(config)),
    // 意见
    consultCreate: (data, config = {}) => http.post('/consult', data, getConfig(config)),
    consultList: (data, config = {}) => http.get('/consult/list', data, getConfig(config)),
    consultDetail: (id, config = {}) => http.get(`/consult/${id}`, {}, getConfig(config)),
    commentCreate: (data, config = {}) => http.post('/comment', data, getConfig(config)),
    newsList: (data, config = {}) => http.get('/news/list', data, getConfig(config)),
    newsDetail: (id, config = {}) => http.get(`/news/${id}`, {}, getConfig(config))
}